<template>
	<div id="app">
		<img alt="Vue logo" src="./assets/logo.png">
		<HelloWorld msg="Welcome to Your Vue.js App" />
		<hr>
		<input type="button" @click="getPrkFlow()" value="点我请求数据" />
		请求返回的数据:{{responseData}}
	</div>
</template>

<script>
	import HelloWorld from './components/HelloWorld.vue'
	import {api} from './api/api.js'
	import axios from 'axios'
	import axioswrapper from './api/axioswrapper.js'
	import {isLocalMock} from './common/common.js'

	export default {
		name: 'app',
		components: {
			HelloWorld
		},
		data: () => {
			return {

				responseData: null
			}
		},
		methods: {
			getPrkFlow() {
				let params = {}
				let headers = {}
				// 使用封装过的axios
				// axioswrapper.post(api.datacentersys.report.prkflow,params,headers)
				// .then((response=>{
				// 	console.group("-----使用axioswrapper请求返回数据-----")
				// 	console.log(response);
				// 	this.responseData = response.data;
				// 	console.groupEnd()
				// }).bind(this)).catch(error => {
				// 	console.log("====")
				// 	console.log(error);
				// });
				
				axioswrapper.post('/apv/report/v2/getReport',params,headers)
				.then((response=>{
					console.group("-----使用axioswrapper请求返回数据-----")
					console.log(response);
					this.responseData = response.data;
					console.groupEnd()
				}).bind(this)).catch(error => {
					console.log("====")
					console.log(error);
				});
				
				//使用原生的axios
// 				let options = {
// 					params: {
// 
// 					}
// 				};
// 				let instance;
// 				if (isLocalMock(api.datacentersys.report.prkflow)) {
// 					instance = axios.get(api.datacentersys.report.prkflow, options);
// 				} else {
// 					instance = axios.post(api.datacentersys.report.prkflow, options);
// 				}
// 				instance.then((response => {
// 					console.group("-----使用原生的axios请求返回数据-----")
// 					console.log(response);
// 					console.log(response.data);
// 					this.responseData = response.data;
// 					console.groupEnd()
// 				}).bind(this)
// 				).catch(error => {
// 					console.log(error);
// 				});
				
			}
		}
	}
</script>

<style>
	#app {
		font-family: 'Avenir', Helvetica, Arial, sans-serif;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
		text-align: center;
		color: #2c3e50;
		margin-top: 60px;
	}
</style>
